<?php
/**
 * Created by phpstorm.
 * User: WML
 * Date: 2019/9/9 0009
 * Time: 11:33
 */
namespace app\chat\controller;

use app\model\Users;
use think\facade\Session;

class Index extends Allow
{
    public function index()
    {
        return view("index");
    }
    public function welcome(){
        $user_id = Session::get('chat_user_id');
//        return $user_id;
//        $users = db("users")->find($user_id);
        $users = Users::get($user_id);
        $this->assign('users',$users);
        return view("welcome");
    }
    public function onLine(){
        if(request()->post()){
            $data = request()->param();
            db("users")->where('id',$data['user_id'])->update(['client_id' => $data['click_id']]);
        }
    }
    public function postCheckUserLine(){
        $data = request()->param();
        Session::set('lineUser',$data);
    }
//    public function outLine(){
//        if(request()->post()){
//            $data = request()->param();
//            $users = db("users")->where('client_id',$data['client_id'])->find();
//            db("users")->where('client_id',$data['client_id'])->update(['client_id' => null]);
//            return ['state' => 200,'data' => $users];
//        }
//    }
}
